home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / Debconf / FrontEnd / Kde.pm < prev    next >
Encoding:
Perl POD Document  |  2009-03-24  |  4.5 KB  |  206 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::FrontEnd::Kde;
  6. use strict;
  7. use utf8;
  8. use Debconf::Gettext;
  9. use Debconf::Config;
  10. BEGIN {
  11.     eval { require Qt };
  12.     die "Unable to load Qt -- is libqt-perl installed?\n" if $@;
  13.     Qt->import;
  14. }
  15. use Debconf::FrontEnd::Kde::Wizard;
  16. use Debconf::Log ':all';
  17. use base qw{Debconf::FrontEnd};
  18. use Debconf::Encoding qw(to_Unicode);
  19.  
  20.  
  21. our @ARGV_KDE=();
  22.  
  23. sub init {
  24.     my $this=shift;
  25.     
  26.     $this->SUPER::init(@_);
  27.     $this->interactive(1);
  28.     $this->cancelled(0);
  29.     $this->createdelements([]);
  30.     $this->dupelements([]);
  31.     $this->capb('backup');
  32.     $this->need_tty(0);
  33.  
  34.     if (fork) {
  35.         wait(); # for child
  36.         if ($? != 0) {
  37.             die "DISPLAY problem?\n";
  38.         }
  39.     }
  40.     else {
  41.         $this->qtapp(Qt::Application(\@ARGV_KDE));
  42.         exit(0); # success
  43.     }
  44.     
  45.     $this->kde_initted(0);
  46. }
  47.  
  48. sub init_kde {
  49.     my $this=shift;
  50.  
  51.     return if $this->kde_initted;
  52.  
  53.     debug frontend => "QTF: initializing app";
  54.     $this->qtapp(Qt::Application(\@ARGV_KDE));
  55.     debug frontend => "QTF: initializing wizard";
  56.     $this->win(Debconf::FrontEnd::Kde::Wizard(undef, undef, $this));
  57.     debug frontend => "QTF: setting size";
  58.     $this->win->resize(620, 430);
  59.     my $hostname = `hostname`;
  60.     chomp $hostname;
  61.     $this->hostname($hostname);
  62.     debug frontend => "QTF: setting title";
  63.     $this->win->setCaption(to_Unicode(sprintf(gettext("Debconf on %s"), $this->hostname)));
  64.     debug frontend => "QTF: initializing main widget";
  65.     $this->toplayout(Qt::HBoxLayout($this->win->mainFrame));
  66.     $this->page(Qt::ScrollView($this->win->mainFrame));
  67.     $this->page->setResizePolicy(&Qt::ScrollView::AutoOneFit());
  68.     $this->page->setFrameStyle(&Qt::Frame::NoFrame());
  69.     $this->frame(Qt::Frame($this->page));
  70.     $this->page->addChild($this->frame);
  71.     $this->toplayout->addWidget($this->page);
  72.     $this->vbox(Qt::VBoxLayout($this->frame, 0, 6, "wizard-main-vbox"));
  73.     $this->space(Qt::SpacerItem(1, 1, 1, 5));
  74.     $this->win->setTitle(to_Unicode(sprintf(gettext("Debconf on %s"), $this->hostname)));
  75.  
  76.     $this->kde_initted(1);
  77. }
  78.  
  79.  
  80. sub go {
  81.     my $this=shift;
  82.     my @elements=@{$this->elements};
  83.     
  84.     my $interactive='';
  85.     debug frontend => "QTF: -- START ------------------";
  86.     foreach my $element (@elements) {
  87.         next unless $element->can("create");
  88.         $this->init_kde();
  89.         $element->create($this->frame);
  90.         $interactive=1;
  91.         debug frontend => "QTF: ADD: " . $element->question->description;
  92.         $this->vbox->addWidget($element->top);
  93.     }
  94.     
  95.     if ($interactive) {
  96.         foreach my $element (@elements) {
  97.             next unless $element->top;
  98.             debug frontend => "QTF: SHOW: " . $element->question->description;
  99.             $element->top->show;
  100.         }
  101.     
  102.         $this->vbox->addItem($this->space);
  103.     
  104.         if ($this->capb_backup) {
  105.             $this->win->setBackEnabled(1);
  106.         }
  107.         else {
  108.             $this->win->setBackEnabled(0);
  109.         }
  110.         $this->win->setNextEnabled(1);
  111.     
  112.         $this->win->show;
  113.         debug frontend => "QTF: -- ENTER EVENTLOOP --------";
  114.         $this->qtapp->exec;
  115.         debug frontend => "QTF: -- LEFT EVENTLOOP --------";
  116.     
  117.         foreach my $element (@elements) {
  118.             next unless $element -> top;
  119.             debug frontend => "QTF: HIDE: " . $element->question->description;
  120.             $this->vbox->remove($element->top);
  121.             $element->top->hide;
  122.             debug frontend => "QTF: DESTROY: " . $element->question->description;
  123.             $element->destroy;
  124.         }
  125.         
  126.         $this->vbox->removeItem($this->space);
  127.     }
  128.     
  129.     foreach my $element (@elements) {
  130.         $element->show;
  131.     }
  132.  
  133.     debug frontend => "QTF: -- END --------------------";
  134.     if ($this->cancelled) {
  135.         exit 1;
  136.     }
  137.     return '' if $this->goback;
  138.     return 1;
  139. }
  140.  
  141. sub progress_start {
  142.     my $this=shift;
  143.     $this->SUPER::progress_start(@_);
  144.  
  145.     my $element=$this->progress_bar;
  146.     $this->vbox->addWidget($element->top);
  147.     $element->top->show;
  148.     $this->vbox->addItem($this->space);
  149.     $this->win->setBackEnabled(0);
  150.     $this->win->setNextEnabled(0);
  151.     $this->win->show;
  152.     $this->qtapp->processEvents;
  153. }
  154.  
  155. sub progress_set {
  156.     my $this=shift;
  157.     my $ret=$this->SUPER::progress_set(@_);
  158.  
  159.     $this->qtapp->processEvents;
  160.  
  161.     return $ret;
  162. }
  163.  
  164. sub progress_info {
  165.     my $this=shift;
  166.     my $ret=$this->SUPER::progress_info(@_);
  167.  
  168.     $this->qtapp->processEvents;
  169.  
  170.     return $ret;
  171. }
  172.  
  173. sub progress_stop {
  174.     my $this=shift;
  175.     my $element=$this->progress_bar;
  176.     $this->SUPER::progress_stop(@_);
  177.  
  178.     $this->qtapp->processEvents;
  179.  
  180.     $this->vbox->remove($element->top);
  181.     $element->top->hide;
  182.     $element->destroy;
  183.     $this->vbox->removeItem($this->space);
  184.  
  185.     if ($this->cancelled) {
  186.         exit 1;
  187.     }
  188. }
  189.  
  190.  
  191. sub shutdown {
  192.     my $this = shift;
  193.     if ($this->kde_initted) {
  194.         $this->win->hide;
  195.         $this->frame->reparent(undef, 0, Qt::Point(0, 0), 0);
  196.         $this->frame(undef);
  197.         $this->win->mainFrame->reparent(undef, 0, Qt::Point(0, 0), 0);
  198.         $this->win->mainFrame(undef);
  199.         $this->win(undef);
  200.         $this->space(undef);
  201.     }
  202. }
  203.  
  204.  
  205. 1
  206.